package com.nullpointer.xchatfinal.fragment;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;

import com.nullpointer.xchatfinal.R;

public class DeleteMessageDialogFragment extends DialogFragment {
	private Button btOK;
	private Button btCancel;
	private onDeleteMessagesDialogFragment listener;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_delete_message,
				container);
		findViewIds(view);
		init();
		setEvent();
		return view;
	}

	private void init() {
		getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
	}

	private void setEvent() {
		btOK.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if(listener != null){
					listener.onDeleteMessage();
				}
				dismiss();
			}
		});

		btCancel.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
	}

	private void findViewIds(View view) {
		btOK = (Button) view.findViewById(R.id.bt_ok);
		btCancel = (Button) view.findViewById(R.id.bt_cancel);
	}

	@Override
	public void onDismiss(DialogInterface dialog) {
		super.onDismiss(dialog);
	}

	@Override
	public void onCancel(DialogInterface dialog) {
		super.onCancel(dialog);
	}
	
	public void setOnDeleteMessagesDialogFragment(onDeleteMessagesDialogFragment listener){
		this.listener = listener;
	}
	
	public interface onDeleteMessagesDialogFragment{
		public void onDeleteMessage();
	}

}
